<template>
  <view class="company-profile-container">
    <!-- 加载状态 -->
    <view v-if="loading" class="loading-container">
      <u-loading-icon mode="circle" size="40"></u-loading-icon>
      <text class="loading-text">{{ useT('加载中.') }}</text>
    </view>

    <!-- 富文本内容 -->
    <view v-else class="content-container">
      <rich-text :nodes="richContent" class="rich-content"></rich-text>
    </view>
  </view>
</template>

<script setup>
import { getCompanyProfile } from '@/api/common.js';
import { onMounted, ref } from 'vue';

// 加载状态
const loading = ref(true);
// 富文本内容
const richContent = ref('');

onMounted(() => {
  // 加载公司简介数据
  loadCompanyProfile();
});

// 加载公司简介数据
const loadCompanyProfile = async () => {
  try {
    loading.value = true;

    // 调用API获取公司简介
    const response = await getCompanyProfile();

    if (response.success && response.data) {
      richContent.value = response.data.content;
    } else {
      throw new Error('数据格式错误');
    }
  } catch (error) {
    console.error('加载公司简介失败:', error);
    uni.showToast({
      title: '加载失败，请重试',
      icon: 'error'
    });
  } finally {
    loading.value = false;
  }
};
</script>

<style lang="scss" scoped>
.company-profile-container {
  min-height: 100vh;
  background-color: #f8f8f8;

  // 加载状态
  .loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 100rpx 0;

    .loading-text {
      margin-top: 20rpx;
      font-size: 28rpx;
      color: #666666;
    }
  }

  // 内容容器
  .content-container {
    .rich-content {
      min-height: 200rpx;
    }
  }
}
</style>
